from Tkinter import *
from tkSimpleDialog import *

class NewScrumDialog(Toplevel):
    """
    Represents the frame that provides a user interface to access a list of existing projects.
    """
    
    def __init__(self, parentControl, listener):
        Toplevel.__init__(self, parentControl)
        
        self.listener = listener
        
        label = Label(self, text="Members:")
        label.grid(row = 0, column = 0)

        self.membersListbox = Listbox(self)
        self.membersListbox.grid(row = 1, column = 0, rowspan = 6)
        
        label = Label(self, text = "Accompli")
        label.grid(row = 0, column = 1)
        
        self.accomplishedTextbox = Text(self, width=30, height=10)
        self.accomplishedTextbox.grid(row = 1, column = 1)
        
        label = Label(self, text = "Problemes")
        label.grid(row = 2, column = 1)
        
        self.problemsTextbox = Text(self, width=30, height=10)
        self.problemsTextbox.grid(row = 3, column = 1)
        
        label = Label(self, text = "Mission")
        label.grid(row = 4, column = 1)
        
        self.missionTextbox = Text(self, width=30, height=10)
        self.missionTextbox.grid(row = 5, column = 1)
        
        button = Button(self, text="Enregistrer", command = self._onSaveClicked)
        button.grid(row = 6, column = 0, columnspan = 2)
        
    def addProjectMemberName(self, name):
        self.membersListbox.insert(END, name)
        
    def getSelectedProjectMemberName(self):
        return self.membersListbox.get(ACTIVE)
        
    def getAccomplished(self):
        return self.accomplishedTextbox.get(1.0, END).strip()
    
    def getProblems(self):
        return self.problemsTextbox.get(1.0, END).strip()
    
    def getMission(self):
        return self.missionTextbox.get(1.0, END).strip()
    
    def _onSaveClicked(self):
        self.listener.onNewScrumSaved()